package com.bysc.commentservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bysc.commentservice.entity.CommentType;
import com.bysc.commentservice.mapper.CommentTypeMapper;
import com.bysc.commentservice.service.CommentTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kkk
 * @since 2024-05-28
 */
@Service
public class CommentTypeServiceImpl extends ServiceImpl<CommentTypeMapper, CommentType> implements CommentTypeService {

    @Override
    public void removeSonCommentTypeById(String id) {
        LambdaQueryWrapper<CommentType> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CommentType::getParentId,id);
        List<CommentType> list = baseMapper.selectList(wrapper);
        ArrayList<String> idList = new ArrayList<>();
        for (CommentType commentType : list) {
            idList.add(commentType.getId());
        }
        baseMapper.deleteBatchIds(idList);
    }
}
